// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate rpc;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Message for request to list Jobs
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListJobsRequest {
    /// Required. Format: projects/{project_id}/locations/global.
    pub parent: std::string::String,

    /// Optional. Filters results as defined by <https://google.aip.dev/160>.
    pub filter: std::string::String,

    /// Optional. The list page size. default page size is 100.
    pub page_size: i32,

    /// Optional. The list page token.
    pub page_token: std::string::String,

    /// Optional. Field to sort by. Supported fields are name, create_time.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListJobsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListJobsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListJobsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListJobsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListJobsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListJobsRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListJobsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.ListJobsRequest"
    }
}

/// Message for response to listing Jobs
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListJobsResponse {
    /// A list of storage batch jobs.
    pub jobs: std::vec::Vec<crate::model::Job>,

    /// A token identifying a page of results.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListJobsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [jobs][crate::model::ListJobsResponse::jobs].
    pub fn set_jobs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Job>,
    {
        use std::iter::Iterator;
        self.jobs = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListJobsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListJobsResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListJobsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.ListJobsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListJobsResponse {
    type PageItem = crate::model::Job;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.jobs
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for getting a Job
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetJobRequest {
    /// Required. `name` of the job to retrieve.
    /// Format: projects/{project_id}/locations/global/jobs/{job_id} .
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetJobRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetJobRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetJobRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.GetJobRequest"
    }
}

/// Message for creating a Job
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateJobRequest {
    /// Required. Value for parent.
    pub parent: std::string::String,

    /// Required. The optional `job_id` for this Job . If not
    /// specified, an id is generated. `job_id` should be no more than 128
    /// characters and must include only characters available in DNS names, as
    /// defined by RFC-1123.
    pub job_id: std::string::String,

    /// Required. The resource being created
    pub job: std::option::Option<crate::model::Job>,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID in case you need to retry your request. Requests with same
    /// `request_id` will be ignored for at least 60 minutes since the first
    /// request. The request ID must be a valid UUID with the exception that zero
    /// UUID is not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateJobRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateJobRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [job_id][crate::model::CreateJobRequest::job_id].
    pub fn set_job_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.job_id = v.into();
        self
    }

    /// Sets the value of [job][crate::model::CreateJobRequest::job].
    pub fn set_job<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Job>,
    {
        self.job = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [job][crate::model::CreateJobRequest::job].
    pub fn set_or_clear_job<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Job>,
    {
        self.job = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::CreateJobRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }
}

impl wkt::message::Message for CreateJobRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.CreateJobRequest"
    }
}

/// Message for Job to Cancel
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CancelJobRequest {
    /// Required. The `name` of the job to cancel.
    /// Format: projects/{project_id}/locations/global/jobs/{job_id}.
    pub name: std::string::String,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID in case you need to retry your request. Requests with same
    /// `request_id` will be ignored for at least 60 minutes since the first
    /// request. The request ID must be a valid UUID with the exception that zero
    /// UUID is not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CancelJobRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::CancelJobRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [request_id][crate::model::CancelJobRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }
}

impl wkt::message::Message for CancelJobRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.CancelJobRequest"
    }
}

/// Message for deleting a Job
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteJobRequest {
    /// Required. The `name` of the job to delete.
    /// Format: projects/{project_id}/locations/global/jobs/{job_id} .
    pub name: std::string::String,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID in case you need to retry your request. Requests with same
    /// `request_id` will be ignored for at least 60 minutes since the first
    /// request. The request ID must be a valid UUID with the exception that zero
    /// UUID is not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteJobRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteJobRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [request_id][crate::model::DeleteJobRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }
}

impl wkt::message::Message for DeleteJobRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.DeleteJobRequest"
    }
}

/// Message for response to cancel Job.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CancelJobResponse {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CancelJobResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for CancelJobResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.CancelJobResponse"
    }
}

/// Represents the metadata of the long-running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// Output only. The unique operation resource name.
    /// Format: projects/{project}/locations/global/operations/{operation}.
    pub operation: std::string::String,

    /// Output only. The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Identifies whether the user has requested cancellation
    /// of the operation. Operations that have been cancelled successfully
    /// have
    /// [google.longrunning.Operation.error][google.longrunning.Operation.error]
    /// value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
    /// corresponding to
    /// `[Code.CANCELLED][google.rpc.Code.CANCELLED]`.
    ///
    /// [google.longrunning.Operation.error]: longrunning::model::Operation::result
    /// [google.rpc.Code.CANCELLED]: rpc::model::Code::Cancelled
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub requested_cancellation: bool,

    /// Output only. API version used to start the operation.
    pub api_version: std::string::String,

    /// Output only. The Job associated with the operation.
    pub job: std::option::Option<crate::model::Job>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [operation][crate::model::OperationMetadata::operation].
    pub fn set_operation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.operation = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [requested_cancellation][crate::model::OperationMetadata::requested_cancellation].
    pub fn set_requested_cancellation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.requested_cancellation = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }

    /// Sets the value of [job][crate::model::OperationMetadata::job].
    pub fn set_job<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Job>,
    {
        self.job = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [job][crate::model::OperationMetadata::job].
    pub fn set_or_clear_job<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Job>,
    {
        self.job = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.OperationMetadata"
    }
}

/// The Storage Batch Operations Job description.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Job {
    /// Identifier. The resource name of the Job. job_id is unique
    /// within the project, that is either set by the customer or
    /// defined by the service. Format:
    /// projects/{project}/locations/global/jobs/{job_id} .
    /// For example: "projects/123456/locations/global/jobs/job01".
    pub name: std::string::String,

    /// Optional. A description provided by the user for the job. Its max length is
    /// 1024 bytes when Unicode-encoded.
    pub description: std::string::String,

    /// Optional. Logging configuration.
    pub logging_config: std::option::Option<crate::model::LoggingConfig>,

    /// Output only. The time that the job was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time that the job was scheduled.
    pub schedule_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time that the job was completed.
    pub complete_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Information about the progress of the job.
    pub counters: std::option::Option<crate::model::Counters>,

    /// Output only. Summarizes errors encountered with sample error log entries.
    pub error_summaries: std::vec::Vec<crate::model::ErrorSummary>,

    /// Output only. State of the job.
    pub state: crate::model::job::State,

    /// Specifies objects to be transformed.
    pub source: std::option::Option<crate::model::job::Source>,

    /// Operation to be performed on the objects.
    pub transformation: std::option::Option<crate::model::job::Transformation>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Job {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Job::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::Job::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [logging_config][crate::model::Job::logging_config].
    pub fn set_logging_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::LoggingConfig>,
    {
        self.logging_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [logging_config][crate::model::Job::logging_config].
    pub fn set_or_clear_logging_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::LoggingConfig>,
    {
        self.logging_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [create_time][crate::model::Job::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Job::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [schedule_time][crate::model::Job::schedule_time].
    pub fn set_schedule_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.schedule_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [schedule_time][crate::model::Job::schedule_time].
    pub fn set_or_clear_schedule_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.schedule_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [complete_time][crate::model::Job::complete_time].
    pub fn set_complete_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.complete_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [complete_time][crate::model::Job::complete_time].
    pub fn set_or_clear_complete_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.complete_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [counters][crate::model::Job::counters].
    pub fn set_counters<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Counters>,
    {
        self.counters = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [counters][crate::model::Job::counters].
    pub fn set_or_clear_counters<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Counters>,
    {
        self.counters = v.map(|x| x.into());
        self
    }

    /// Sets the value of [error_summaries][crate::model::Job::error_summaries].
    pub fn set_error_summaries<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ErrorSummary>,
    {
        use std::iter::Iterator;
        self.error_summaries = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [state][crate::model::Job::state].
    pub fn set_state<T: std::convert::Into<crate::model::job::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [source][crate::model::Job::source].
    ///
    /// Note that all the setters affecting `source` are mutually
    /// exclusive.
    pub fn set_source<T: std::convert::Into<std::option::Option<crate::model::job::Source>>>(
        mut self,
        v: T,
    ) -> Self {
        self.source = v.into();
        self
    }

    /// The value of [source][crate::model::Job::source]
    /// if it holds a `BucketList`, `None` if the field is not set or
    /// holds a different branch.
    pub fn bucket_list(&self) -> std::option::Option<&std::boxed::Box<crate::model::BucketList>> {
        #[allow(unreachable_patterns)]
        self.source.as_ref().and_then(|v| match v {
            crate::model::job::Source::BucketList(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [source][crate::model::Job::source]
    /// to hold a `BucketList`.
    ///
    /// Note that all the setters affecting `source` are
    /// mutually exclusive.
    pub fn set_bucket_list<T: std::convert::Into<std::boxed::Box<crate::model::BucketList>>>(
        mut self,
        v: T,
    ) -> Self {
        self.source = std::option::Option::Some(crate::model::job::Source::BucketList(v.into()));
        self
    }

    /// Sets the value of [transformation][crate::model::Job::transformation].
    ///
    /// Note that all the setters affecting `transformation` are mutually
    /// exclusive.
    pub fn set_transformation<
        T: std::convert::Into<std::option::Option<crate::model::job::Transformation>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.transformation = v.into();
        self
    }

    /// The value of [transformation][crate::model::Job::transformation]
    /// if it holds a `PutObjectHold`, `None` if the field is not set or
    /// holds a different branch.
    pub fn put_object_hold(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::PutObjectHold>> {
        #[allow(unreachable_patterns)]
        self.transformation.as_ref().and_then(|v| match v {
            crate::model::job::Transformation::PutObjectHold(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [transformation][crate::model::Job::transformation]
    /// to hold a `PutObjectHold`.
    ///
    /// Note that all the setters affecting `transformation` are
    /// mutually exclusive.
    pub fn set_put_object_hold<
        T: std::convert::Into<std::boxed::Box<crate::model::PutObjectHold>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.transformation =
            std::option::Option::Some(crate::model::job::Transformation::PutObjectHold(v.into()));
        self
    }

    /// The value of [transformation][crate::model::Job::transformation]
    /// if it holds a `DeleteObject`, `None` if the field is not set or
    /// holds a different branch.
    pub fn delete_object(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::DeleteObject>> {
        #[allow(unreachable_patterns)]
        self.transformation.as_ref().and_then(|v| match v {
            crate::model::job::Transformation::DeleteObject(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [transformation][crate::model::Job::transformation]
    /// to hold a `DeleteObject`.
    ///
    /// Note that all the setters affecting `transformation` are
    /// mutually exclusive.
    pub fn set_delete_object<T: std::convert::Into<std::boxed::Box<crate::model::DeleteObject>>>(
        mut self,
        v: T,
    ) -> Self {
        self.transformation =
            std::option::Option::Some(crate::model::job::Transformation::DeleteObject(v.into()));
        self
    }

    /// The value of [transformation][crate::model::Job::transformation]
    /// if it holds a `PutMetadata`, `None` if the field is not set or
    /// holds a different branch.
    pub fn put_metadata(&self) -> std::option::Option<&std::boxed::Box<crate::model::PutMetadata>> {
        #[allow(unreachable_patterns)]
        self.transformation.as_ref().and_then(|v| match v {
            crate::model::job::Transformation::PutMetadata(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [transformation][crate::model::Job::transformation]
    /// to hold a `PutMetadata`.
    ///
    /// Note that all the setters affecting `transformation` are
    /// mutually exclusive.
    pub fn set_put_metadata<T: std::convert::Into<std::boxed::Box<crate::model::PutMetadata>>>(
        mut self,
        v: T,
    ) -> Self {
        self.transformation =
            std::option::Option::Some(crate::model::job::Transformation::PutMetadata(v.into()));
        self
    }

    /// The value of [transformation][crate::model::Job::transformation]
    /// if it holds a `RewriteObject`, `None` if the field is not set or
    /// holds a different branch.
    pub fn rewrite_object(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::RewriteObject>> {
        #[allow(unreachable_patterns)]
        self.transformation.as_ref().and_then(|v| match v {
            crate::model::job::Transformation::RewriteObject(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [transformation][crate::model::Job::transformation]
    /// to hold a `RewriteObject`.
    ///
    /// Note that all the setters affecting `transformation` are
    /// mutually exclusive.
    pub fn set_rewrite_object<
        T: std::convert::Into<std::boxed::Box<crate::model::RewriteObject>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.transformation =
            std::option::Option::Some(crate::model::job::Transformation::RewriteObject(v.into()));
        self
    }
}

impl wkt::message::Message for Job {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.Job"
    }
}

/// Defines additional types related to [Job].
pub mod job {
    #[allow(unused_imports)]
    use super::*;

    /// Describes state of a job.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Default value. This value is unused.
        Unspecified,
        /// In progress.
        Running,
        /// Completed successfully.
        Succeeded,
        /// Cancelled by the user.
        Canceled,
        /// Terminated due to an unrecoverable failure.
        Failed,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Running => std::option::Option::Some(1),
                Self::Succeeded => std::option::Option::Some(2),
                Self::Canceled => std::option::Option::Some(3),
                Self::Failed => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Running => std::option::Option::Some("RUNNING"),
                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
                Self::Canceled => std::option::Option::Some("CANCELED"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Running,
                2 => Self::Succeeded,
                3 => Self::Canceled,
                4 => Self::Failed,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "RUNNING" => Self::Running,
                "SUCCEEDED" => Self::Succeeded,
                "CANCELED" => Self::Canceled,
                "FAILED" => Self::Failed,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Running => serializer.serialize_i32(1),
                Self::Succeeded => serializer.serialize_i32(2),
                Self::Canceled => serializer.serialize_i32(3),
                Self::Failed => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.storagebatchoperations.v1.Job.State",
            ))
        }
    }

    /// Specifies objects to be transformed.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Source {
        /// Specifies a list of buckets and their objects to be transformed.
        BucketList(std::boxed::Box<crate::model::BucketList>),
    }

    /// Operation to be performed on the objects.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Transformation {
        /// Changes object hold status.
        PutObjectHold(std::boxed::Box<crate::model::PutObjectHold>),
        /// Delete objects.
        DeleteObject(std::boxed::Box<crate::model::DeleteObject>),
        /// Updates object metadata. Allows updating fixed-key and custom metadata
        /// and fixed-key metadata i.e. Cache-Control, Content-Disposition,
        /// Content-Encoding, Content-Language, Content-Type, Custom-Time.
        PutMetadata(std::boxed::Box<crate::model::PutMetadata>),
        /// Rewrite the object and updates metadata like KMS key.
        RewriteObject(std::boxed::Box<crate::model::RewriteObject>),
    }
}

/// Describes list of buckets and their objects to be transformed.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BucketList {
    /// Required. List of buckets and their objects to be transformed. Currently,
    /// only one bucket configuration is supported. If multiple buckets are
    /// specified, an error will be returned.
    pub buckets: std::vec::Vec<crate::model::bucket_list::Bucket>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BucketList {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [buckets][crate::model::BucketList::buckets].
    pub fn set_buckets<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::bucket_list::Bucket>,
    {
        use std::iter::Iterator;
        self.buckets = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for BucketList {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.BucketList"
    }
}

/// Defines additional types related to [BucketList].
pub mod bucket_list {
    #[allow(unused_imports)]
    use super::*;

    /// Describes configuration of a single bucket and its objects to be
    /// transformed.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Bucket {
        /// Required. Bucket name for the objects to be transformed.
        pub bucket: std::string::String,

        /// Specifies objects to be transformed.
        pub object_configuration:
            std::option::Option<crate::model::bucket_list::bucket::ObjectConfiguration>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Bucket {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [bucket][crate::model::bucket_list::Bucket::bucket].
        pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.bucket = v.into();
            self
        }

        /// Sets the value of [object_configuration][crate::model::bucket_list::Bucket::object_configuration].
        ///
        /// Note that all the setters affecting `object_configuration` are mutually
        /// exclusive.
        pub fn set_object_configuration<
            T: std::convert::Into<
                    std::option::Option<crate::model::bucket_list::bucket::ObjectConfiguration>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.object_configuration = v.into();
            self
        }

        /// The value of [object_configuration][crate::model::bucket_list::Bucket::object_configuration]
        /// if it holds a `PrefixList`, `None` if the field is not set or
        /// holds a different branch.
        pub fn prefix_list(
            &self,
        ) -> std::option::Option<&std::boxed::Box<crate::model::PrefixList>> {
            #[allow(unreachable_patterns)]
            self.object_configuration.as_ref().and_then(|v| match v {
                crate::model::bucket_list::bucket::ObjectConfiguration::PrefixList(v) => {
                    std::option::Option::Some(v)
                }
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [object_configuration][crate::model::bucket_list::Bucket::object_configuration]
        /// to hold a `PrefixList`.
        ///
        /// Note that all the setters affecting `object_configuration` are
        /// mutually exclusive.
        pub fn set_prefix_list<T: std::convert::Into<std::boxed::Box<crate::model::PrefixList>>>(
            mut self,
            v: T,
        ) -> Self {
            self.object_configuration = std::option::Option::Some(
                crate::model::bucket_list::bucket::ObjectConfiguration::PrefixList(v.into()),
            );
            self
        }

        /// The value of [object_configuration][crate::model::bucket_list::Bucket::object_configuration]
        /// if it holds a `Manifest`, `None` if the field is not set or
        /// holds a different branch.
        pub fn manifest(&self) -> std::option::Option<&std::boxed::Box<crate::model::Manifest>> {
            #[allow(unreachable_patterns)]
            self.object_configuration.as_ref().and_then(|v| match v {
                crate::model::bucket_list::bucket::ObjectConfiguration::Manifest(v) => {
                    std::option::Option::Some(v)
                }
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [object_configuration][crate::model::bucket_list::Bucket::object_configuration]
        /// to hold a `Manifest`.
        ///
        /// Note that all the setters affecting `object_configuration` are
        /// mutually exclusive.
        pub fn set_manifest<T: std::convert::Into<std::boxed::Box<crate::model::Manifest>>>(
            mut self,
            v: T,
        ) -> Self {
            self.object_configuration = std::option::Option::Some(
                crate::model::bucket_list::bucket::ObjectConfiguration::Manifest(v.into()),
            );
            self
        }
    }

    impl wkt::message::Message for Bucket {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.storagebatchoperations.v1.BucketList.Bucket"
        }
    }

    /// Defines additional types related to [Bucket].
    pub mod bucket {
        #[allow(unused_imports)]
        use super::*;

        /// Specifies objects to be transformed.
        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum ObjectConfiguration {
            /// Specifies objects matching a prefix set.
            PrefixList(std::boxed::Box<crate::model::PrefixList>),
            /// Specifies objects in a manifest file.
            Manifest(std::boxed::Box<crate::model::Manifest>),
        }
    }
}

/// Describes list of objects to be transformed.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Manifest {
    /// Required. `manifest_location` must contain the manifest source file that is
    /// a CSV file in a Google Cloud Storage bucket. Each row in the file must
    /// include the object details i.e. BucketId and Name. Generation may
    /// optionally be specified. When it is not specified the live object is acted
    /// upon.
    /// `manifest_location` should either be
    ///
    /// 1. An absolute path to the object in the format of
    ///    `gs://bucket_name/path/file_name.csv`.
    /// 1. An absolute path with a single wildcard character in the file name, for
    ///    example `gs://bucket_name/path/file_name*.csv`.
    ///    If manifest location is specified with a wildcard, objects in all manifest
    ///    files matching the pattern will be acted upon.
    pub manifest_location: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Manifest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [manifest_location][crate::model::Manifest::manifest_location].
    pub fn set_manifest_location<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.manifest_location = v.into();
        self
    }
}

impl wkt::message::Message for Manifest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.Manifest"
    }
}

/// Describes prefixes of objects to be transformed.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PrefixList {
    /// Optional. Include prefixes of the objects to be transformed.
    ///
    /// * Supports full object name
    /// * Supports prefix of the object name
    /// * Wildcards are not supported
    /// * Supports empty string for all objects in a bucket.
    pub included_object_prefixes: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PrefixList {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [included_object_prefixes][crate::model::PrefixList::included_object_prefixes].
    pub fn set_included_object_prefixes<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.included_object_prefixes = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for PrefixList {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.PrefixList"
    }
}

/// Describes options to update object hold.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PutObjectHold {
    /// Required. Updates object temporary holds state. When object temporary hold
    /// is set, object cannot be deleted or replaced.
    pub temporary_hold: crate::model::put_object_hold::HoldStatus,

    /// Required. Updates object event based holds state. When object event based
    /// hold is set, object cannot be deleted or replaced. Resets object's time in
    /// the bucket for the purposes of the retention period.
    pub event_based_hold: crate::model::put_object_hold::HoldStatus,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PutObjectHold {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [temporary_hold][crate::model::PutObjectHold::temporary_hold].
    pub fn set_temporary_hold<T: std::convert::Into<crate::model::put_object_hold::HoldStatus>>(
        mut self,
        v: T,
    ) -> Self {
        self.temporary_hold = v.into();
        self
    }

    /// Sets the value of [event_based_hold][crate::model::PutObjectHold::event_based_hold].
    pub fn set_event_based_hold<
        T: std::convert::Into<crate::model::put_object_hold::HoldStatus>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.event_based_hold = v.into();
        self
    }
}

impl wkt::message::Message for PutObjectHold {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.PutObjectHold"
    }
}

/// Defines additional types related to [PutObjectHold].
pub mod put_object_hold {
    #[allow(unused_imports)]
    use super::*;

    /// Describes the status of the hold.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum HoldStatus {
        /// Default value, Object hold status will not be changed.
        Unspecified,
        /// Places the hold.
        Set,
        /// Releases the hold.
        Unset,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [HoldStatus::value] or
        /// [HoldStatus::name].
        UnknownValue(hold_status::UnknownValue),
    }

    #[doc(hidden)]
    pub mod hold_status {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl HoldStatus {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Set => std::option::Option::Some(1),
                Self::Unset => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("HOLD_STATUS_UNSPECIFIED"),
                Self::Set => std::option::Option::Some("SET"),
                Self::Unset => std::option::Option::Some("UNSET"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for HoldStatus {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for HoldStatus {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for HoldStatus {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Set,
                2 => Self::Unset,
                _ => Self::UnknownValue(hold_status::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for HoldStatus {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "HOLD_STATUS_UNSPECIFIED" => Self::Unspecified,
                "SET" => Self::Set,
                "UNSET" => Self::Unset,
                _ => Self::UnknownValue(hold_status::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for HoldStatus {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Set => serializer.serialize_i32(1),
                Self::Unset => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for HoldStatus {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<HoldStatus>::new(
                ".google.cloud.storagebatchoperations.v1.PutObjectHold.HoldStatus",
            ))
        }
    }
}

/// Describes options to delete an object.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteObject {
    /// Required. Controls deletion behavior when versioning is enabled for the
    /// object's bucket. If true both live and noncurrent objects will be
    /// permanently deleted. Otherwise live objects in versioned buckets will
    /// become noncurrent and objects that were already noncurrent will be skipped.
    /// This setting doesn't have any impact on the Soft Delete feature. All
    /// objects deleted by this service can be be restored for the duration of the
    /// Soft Delete retention duration if enabled. If enabled and the manifest
    /// doesn't specify an object's generation, a GetObjectMetadata call (a Class B
    /// operation) will be made to determine the live object generation.
    pub permanent_object_deletion_enabled: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteObject {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [permanent_object_deletion_enabled][crate::model::DeleteObject::permanent_object_deletion_enabled].
    pub fn set_permanent_object_deletion_enabled<T: std::convert::Into<bool>>(
        mut self,
        v: T,
    ) -> Self {
        self.permanent_object_deletion_enabled = v.into();
        self
    }
}

impl wkt::message::Message for DeleteObject {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.DeleteObject"
    }
}

/// Describes options for object rewrite.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RewriteObject {
    /// Required. Resource name of the Cloud KMS key that will be used to encrypt
    /// the object. The Cloud KMS key must be located in same location as the
    /// object. Refer to
    /// <https://cloud.google.com/storage/docs/encryption/using-customer-managed-keys#add-object-key>
    /// for additional documentation. Format:
    /// projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}
    /// For example:
    /// "projects/123456/locations/us-central1/keyRings/my-keyring/cryptoKeys/my-key".
    /// The object will be rewritten and set with the specified KMS key.
    pub kms_key: std::option::Option<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RewriteObject {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [kms_key][crate::model::RewriteObject::kms_key].
    pub fn set_kms_key<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.kms_key = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [kms_key][crate::model::RewriteObject::kms_key].
    pub fn set_or_clear_kms_key<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.kms_key = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for RewriteObject {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.RewriteObject"
    }
}

/// Describes options for object metadata update.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PutMetadata {
    /// Optional. Updates objects Content-Disposition fixed metadata. Unset values
    /// will be ignored. Set empty values to clear the metadata. Refer
    /// <https://cloud.google.com/storage/docs/metadata#content-disposition> for
    /// additional documentation.
    pub content_disposition: std::option::Option<std::string::String>,

    /// Optional. Updates objects Content-Encoding fixed metadata. Unset values
    /// will be ignored. Set empty values to clear the metadata. Refer to
    /// documentation in
    /// <https://cloud.google.com/storage/docs/metadata#content-encoding>.
    pub content_encoding: std::option::Option<std::string::String>,

    /// Optional. Updates objects Content-Language fixed metadata. Refer to ISO
    /// 639-1 language codes for typical values of this metadata. Max length 100
    /// characters. Unset values will be ignored. Set empty values to clear the
    /// metadata. Refer to documentation in
    /// <https://cloud.google.com/storage/docs/metadata#content-language>.
    pub content_language: std::option::Option<std::string::String>,

    /// Optional. Updates objects Content-Type fixed metadata. Unset values will be
    /// ignored.
    /// Set empty values to clear the metadata. Refer to documentation in
    /// <https://cloud.google.com/storage/docs/metadata#content-type>
    pub content_type: std::option::Option<std::string::String>,

    /// Optional. Updates objects Cache-Control fixed metadata. Unset values will
    /// be
    /// ignored. Set empty values to clear the metadata.
    /// Additionally, the value for Custom-Time cannot decrease. Refer to
    /// documentation in
    /// <https://cloud.google.com/storage/docs/metadata#caching_data>.
    pub cache_control: std::option::Option<std::string::String>,

    /// Optional. Updates objects Custom-Time fixed metadata. Unset values will be
    /// ignored. Set empty values to clear the metadata. Refer to documentation in
    /// <https://cloud.google.com/storage/docs/metadata#custom-time>.
    pub custom_time: std::option::Option<std::string::String>,

    /// Optional. Updates objects custom metadata. Adds or sets individual custom
    /// metadata key value pairs on objects. Keys that are set with empty custom
    /// metadata values will have its value cleared. Existing custom metadata not
    /// specified with this flag is not changed. Refer to documentation in
    /// <https://cloud.google.com/storage/docs/metadata#custom-metadata>
    pub custom_metadata: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PutMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [content_disposition][crate::model::PutMetadata::content_disposition].
    pub fn set_content_disposition<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_disposition = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [content_disposition][crate::model::PutMetadata::content_disposition].
    pub fn set_or_clear_content_disposition<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_disposition = v.map(|x| x.into());
        self
    }

    /// Sets the value of [content_encoding][crate::model::PutMetadata::content_encoding].
    pub fn set_content_encoding<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_encoding = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [content_encoding][crate::model::PutMetadata::content_encoding].
    pub fn set_or_clear_content_encoding<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_encoding = v.map(|x| x.into());
        self
    }

    /// Sets the value of [content_language][crate::model::PutMetadata::content_language].
    pub fn set_content_language<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_language = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [content_language][crate::model::PutMetadata::content_language].
    pub fn set_or_clear_content_language<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_language = v.map(|x| x.into());
        self
    }

    /// Sets the value of [content_type][crate::model::PutMetadata::content_type].
    pub fn set_content_type<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_type = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [content_type][crate::model::PutMetadata::content_type].
    pub fn set_or_clear_content_type<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.content_type = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cache_control][crate::model::PutMetadata::cache_control].
    pub fn set_cache_control<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.cache_control = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cache_control][crate::model::PutMetadata::cache_control].
    pub fn set_or_clear_cache_control<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.cache_control = v.map(|x| x.into());
        self
    }

    /// Sets the value of [custom_time][crate::model::PutMetadata::custom_time].
    pub fn set_custom_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.custom_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [custom_time][crate::model::PutMetadata::custom_time].
    pub fn set_or_clear_custom_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<std::string::String>,
    {
        self.custom_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [custom_metadata][crate::model::PutMetadata::custom_metadata].
    pub fn set_custom_metadata<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.custom_metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for PutMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.PutMetadata"
    }
}

/// A summary of errors by error code, plus a count and sample error log
/// entries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ErrorSummary {
    /// Required. The canonical error code.
    pub error_code: rpc::model::Code,

    /// Required. Number of errors encountered per `error_code`.
    pub error_count: i64,

    /// Required. Sample error logs.
    pub error_log_entries: std::vec::Vec<crate::model::ErrorLogEntry>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ErrorSummary {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [error_code][crate::model::ErrorSummary::error_code].
    pub fn set_error_code<T: std::convert::Into<rpc::model::Code>>(mut self, v: T) -> Self {
        self.error_code = v.into();
        self
    }

    /// Sets the value of [error_count][crate::model::ErrorSummary::error_count].
    pub fn set_error_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.error_count = v.into();
        self
    }

    /// Sets the value of [error_log_entries][crate::model::ErrorSummary::error_log_entries].
    pub fn set_error_log_entries<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ErrorLogEntry>,
    {
        use std::iter::Iterator;
        self.error_log_entries = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ErrorSummary {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.ErrorSummary"
    }
}

/// An entry describing an error that has occurred.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ErrorLogEntry {
    /// Required. Output only. Object URL. e.g. gs://my_bucket/object.txt
    pub object_uri: std::string::String,

    /// Optional. Output only. At most 5 error log entries are recorded for a given
    /// error code for a job.
    pub error_details: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ErrorLogEntry {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [object_uri][crate::model::ErrorLogEntry::object_uri].
    pub fn set_object_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.object_uri = v.into();
        self
    }

    /// Sets the value of [error_details][crate::model::ErrorLogEntry::error_details].
    pub fn set_error_details<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.error_details = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ErrorLogEntry {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.ErrorLogEntry"
    }
}

/// Describes details about the progress of the job.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Counters {
    /// Output only. Number of objects listed.
    pub total_object_count: i64,

    /// Output only. Number of objects completed.
    pub succeeded_object_count: i64,

    /// Output only. Number of objects failed.
    pub failed_object_count: i64,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Counters {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [total_object_count][crate::model::Counters::total_object_count].
    pub fn set_total_object_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.total_object_count = v.into();
        self
    }

    /// Sets the value of [succeeded_object_count][crate::model::Counters::succeeded_object_count].
    pub fn set_succeeded_object_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.succeeded_object_count = v.into();
        self
    }

    /// Sets the value of [failed_object_count][crate::model::Counters::failed_object_count].
    pub fn set_failed_object_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.failed_object_count = v.into();
        self
    }
}

impl wkt::message::Message for Counters {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.Counters"
    }
}

/// Specifies the Cloud Logging behavior.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct LoggingConfig {
    /// Required. Specifies the actions to be logged.
    pub log_actions: std::vec::Vec<crate::model::logging_config::LoggableAction>,

    /// Required. States in which Action are logged.If empty, no logs are
    /// generated.
    pub log_action_states: std::vec::Vec<crate::model::logging_config::LoggableActionState>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl LoggingConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [log_actions][crate::model::LoggingConfig::log_actions].
    pub fn set_log_actions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::logging_config::LoggableAction>,
    {
        use std::iter::Iterator;
        self.log_actions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [log_action_states][crate::model::LoggingConfig::log_action_states].
    pub fn set_log_action_states<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::logging_config::LoggableActionState>,
    {
        use std::iter::Iterator;
        self.log_action_states = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for LoggingConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.storagebatchoperations.v1.LoggingConfig"
    }
}

/// Defines additional types related to [LoggingConfig].
pub mod logging_config {
    #[allow(unused_imports)]
    use super::*;

    /// Loggable actions types.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum LoggableAction {
        /// Illegal value, to avoid allowing a default.
        Unspecified,
        /// The corresponding transform action in this job.
        Transform,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [LoggableAction::value] or
        /// [LoggableAction::name].
        UnknownValue(loggable_action::UnknownValue),
    }

    #[doc(hidden)]
    pub mod loggable_action {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl LoggableAction {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Transform => std::option::Option::Some(6),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("LOGGABLE_ACTION_UNSPECIFIED"),
                Self::Transform => std::option::Option::Some("TRANSFORM"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for LoggableAction {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for LoggableAction {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for LoggableAction {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                6 => Self::Transform,
                _ => Self::UnknownValue(loggable_action::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for LoggableAction {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "LOGGABLE_ACTION_UNSPECIFIED" => Self::Unspecified,
                "TRANSFORM" => Self::Transform,
                _ => Self::UnknownValue(loggable_action::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for LoggableAction {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Transform => serializer.serialize_i32(6),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for LoggableAction {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<LoggableAction>::new(
                ".google.cloud.storagebatchoperations.v1.LoggingConfig.LoggableAction",
            ))
        }
    }

    /// Loggable action states filter.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum LoggableActionState {
        /// Illegal value, to avoid allowing a default.
        Unspecified,
        /// `LoggableAction` completed successfully. `SUCCEEDED` actions are
        /// logged as [INFO][google.logging.type.LogSeverity.INFO].
        Succeeded,
        /// `LoggableAction` terminated in an error state. `FAILED` actions
        /// are logged as [ERROR][google.logging.type.LogSeverity.ERROR].
        Failed,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [LoggableActionState::value] or
        /// [LoggableActionState::name].
        UnknownValue(loggable_action_state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod loggable_action_state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl LoggableActionState {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Succeeded => std::option::Option::Some(1),
                Self::Failed => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("LOGGABLE_ACTION_STATE_UNSPECIFIED"),
                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for LoggableActionState {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for LoggableActionState {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for LoggableActionState {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Succeeded,
                2 => Self::Failed,
                _ => Self::UnknownValue(loggable_action_state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for LoggableActionState {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "LOGGABLE_ACTION_STATE_UNSPECIFIED" => Self::Unspecified,
                "SUCCEEDED" => Self::Succeeded,
                "FAILED" => Self::Failed,
                _ => Self::UnknownValue(loggable_action_state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for LoggableActionState {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Succeeded => serializer.serialize_i32(1),
                Self::Failed => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for LoggableActionState {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<LoggableActionState>::new(
                ".google.cloud.storagebatchoperations.v1.LoggingConfig.LoggableActionState",
            ))
        }
    }
}
